const Router = require('koa-router');
const router = new Router();

// 身份验证
const {authMiddleware} = require('../middlewares/authMiddleware')
// 业务层
const {
  createCourse,
  getAllCourses,
  getCourseById,
  updateCourse,
  deleteCourse,
  publishCourse,
  unpublishCourse,
  deleteCourses,
} = require('../controllers/courseController')

// 创建课程
router.post('/', authMiddleware, createCourse);

// 获取所有课程
router.get('/', getAllCourses);

// 获取单个课程
router.get('/:id', getCourseById);

// 更新课程
router.put('/:id', authMiddleware, updateCourse);

// 删除课程
router.delete('/:id', authMiddleware, deleteCourse);

// 上架课程
router.put('/:id/publish', authMiddleware, publishCourse);

// 下架课程
router.put('/:id/unpublish', authMiddleware, unpublishCourse);

// 批量删除课程
router.delete('/', authMiddleware, deleteCourses);

module.exports = router;
